package com.hema.auction.utils;

import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.hema.auction.R;
import com.yqritc.recyclerviewflexibledivider.FlexibleDividerDecoration;
import com.yqritc.recyclerviewflexibledivider.HorizontalDividerItemDecoration;

/**
 * author by john
 */

public class ViewUtils {

    public static void configRecyclerView(Context context,RecyclerView recyclerView) {
        LinearLayoutManager layoutManager = new LinearLayoutManager(context);
        layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(layoutManager);
        FlexibleDividerDecoration.VisibilityProvider visibilityProvider = (FlexibleDividerDecoration.VisibilityProvider) recyclerView.getAdapter();
        HorizontalDividerItemDecoration itemDecoration = null;
        if (visibilityProvider == null) {
            itemDecoration = new HorizontalDividerItemDecoration.Builder(context)
                    .colorResId(R.color.colorDivider)
                    .size(1)
                    .build();
        } else {
            itemDecoration = new HorizontalDividerItemDecoration.Builder(context)
                    .colorResId(R.color.colorDivider)
                    .visibilityProvider(visibilityProvider)
                    .size(1)
                    .build();
        }
        recyclerView.addItemDecoration(itemDecoration);
    }

}
